<!DOCTYPE HTML>
<html>
<head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <base href="http://clickmobile.com/" />
  <link rel="stylesheet" type="text/css" href="<?php echo $stylePath.'css/bootstrap.min.css' ;?>">
  <link rel="stylesheet" type="text/css" href="<?php echo $stylePath.'css/otherstyle.css';?>">
  <script type="text/javascript" src="<?php echo $stylePath.'js/jquery.min.js'; ?>"></script>
  <script type="text/javascript">
  function checkAdd()
  {
    var checkEmail =  $('#check-email').html();
    var password = $('#add-password').val();  
    if(checkEmail == '<img src="styles/admin/img/notok.png">')
    {
      alert('Email không hợp lệ');
      return false;
    }
    else if (password.length <3)
    {
      alert('Mật khẩu phải lớn hơn 3 kí tự');
      return false;
    }
    else return true;
  }
  </script>   
</head>
<body>
  <div class="container well">
    <div class="row">
      <div class="span2">
      <div class="logo"></div>
      </div>
      <div class="span3 offset7">
        <div class="account">
          <div class="btn-group pull-right">
                <a class="btn btn-info" href="admin.php/account"><i class="icon-user icon-white"></i>Thông tin tài khoản</a>
                <a class="btn btn-info" href="admin.php/login/logout"><i class="icon-off icon-white"></i></a>
              </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="span12">
      <div class="navbar">
            <div class="navbar-inner">
                <div class="container">
                  <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                  </a>
                  <a class="brand" href="admin.php/home">Quản trị</a>
                  <div class="nav-collapse">
                    <ul class="nav">
                      <li class="divider-vertical"></li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Người dùng <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                          <li><a href="admin.php/user">Danh sách</a></li>
                          <li class="divider"></li>
                          <li><a href="admin.php/user/add">Thêm mới</a></li>
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Sản phẩm <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                          <li class="nav-header">Sản phẩm</li>                          
                          <li><a href="#">Danh mục</a></li>
                          <li><a href="#">Thêm mới</a></li>
                          <li class="divider"></li>
                          <li class="nav-header">Nhóm sản phẩm</li>
                          <li><a href="#">Nhóm sản phẩm</a></li>
                          <li><a href="#">Nhà sản xuất</a></li>
                          <li class="divider"></li>
                          <li class="nav-header">Thuộc tính</li>
                          <li><a href="#">Danh mục</a></li>                                                    
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>                      
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Bán hàng <b class="caret"></b></a>
                        <ul class="dropdown-menu">                         
                          <li><a href="#">Đơn hàng</a></li>
                          <li class="divider"></li>                      
                          <li><a href="#">Phương thức thanh toán</a></li>
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>                                            
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Mở rộng <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                          <li class="nav-header">Thông tin</li>                          
                          <li><a href="#">Trang thông tin</a></li>
                          <li class="divider"></li>
                          <li class="nav-header">Mở rộng</li>
                          <li><a href="#">SlideShow</a></li>
                          <li><a href="#">Banner</a></li>                         
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>                                            
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Báo cáo - thống kê <b class="caret"></b></a>
                        <ul class="dropdown-menu">                        
                          <li><a href="#">Xuất dữ liệu</a></li>
                          <li class="divider"></li>
                          <li><a href="#">Báo cáo</a></li>
                          <li class="divider"></li>
                          <li><a href="#">Biểu đồ</a></li>
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>                                            
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hệ thống <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                        </ul>
                      </li>
                      <li class="divider-vertical"></li>                                            

                    </ul>
                  </div><!-- /.nav-collapse -->
                </div>
              </div><!-- /navbar-inner -->
            </div>
      </div>
    </div>
  	<div class="row">
  		<div class="span2 side-bar">
        <ul class="nav nav-list">
          <li class="nav-header">Quản trị người dùng</li>
          <li><a href="admin.php/user">Danh sách</a></li>
          <li class="active"><a href="admin.php/user/add">Thêm mới</a></li>
        </ul>
  		</div>
      <div class="span9  main-content">
        <div class="span5 offset2">
          <form class="form-horizontal" method="get" onsubmit="return checkAdd()">
            <legend>Thêm mới người dùng</legend>
            <div class="control-group">
              <label class="control-label" for="add-email">Email</label>
              <div class="controls">
                <input type="text" id="add-email" name="add-email" placeholder="Email" style="float:left; margin-right:10px" onKeyPress="return disableEnterKey(event)" >
                <div id="check-email"></div>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="add-password">Mật khẩu</label>
              <div class="controls">
                <input type="password" id="add-password" name="add-password" placeholder="Mật khẩu" onKeyPress="return disableEnterKey(event)">
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="add-name">Tên</label>
              <div class="controls">
                <input type="text" id="add-name" placeholder="Tên" name="add-name" onKeyPress="return disableEnterKey(event)">
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="add-birthday">Ngày sinh</label>
              <div class="controls">
                <input type="date" id="add-birthday" name="add-birthday" placeholder="Ngày sinh" onKeyPress="return disableEnterKey(event)">
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="add-phone">Điện thoại</label>
              <div class="controls">
                <input type="text" id="add-phone" name="add-phone" placeholder="Điện thoại" onKeyPress="return disableEnterKey(event)">
              </div>
            </div>                              
            <div class="control-group">
              <div class="controls">
                <button type="submit" id="" class="btn btn-success">Thêm mới</button>
                <button type="reset" id="action-reset"  class="btn btn-danger">Làm lại</button>
              </div>
            </div>
          </form>        
        </div>
      </div>
  	</div>
  	<div class="row">
  		<div class="span12 footer">
	        <a href="admin.php"> Trang quản trị </a> | <a href="index.php"> Trang người dùng </a> | <a href="#"> Trợ giúp kĩ thuật </a>
	        <div class="pull-right">
	        <a href="#">© 2012 ClickMobile</a>  
          <img src="">
        </div>
  		</div>
  	</div>   
  </div>
<script type="text/javascript" src="<?php echo $stylePath.'js/jquery.min.js'; ?>"></script>
<script type="text/javascript" src="<?php echo $stylePath.'js/bootstrap.min.js';?>"></script> 
<script type="text/javascript">

  function disableEnterKey(e)
  {
       var key;
       if(window.event)
            key = window.event.keyCode;    
       else
            key = e.which;     
       if(key == 13)
            return false;
       else
            return true;
  }  
  function validateEmail(emailaddress){
     var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;  
     if(!emailReg.test(emailaddress)) {  
        return false;
     }
     else {
        return true;
     }       
  }
  $("#add-email").keyup(function(e){
    var email =  $("#add-email").val();
    if (email.length == 0)
    {
      var style = "<?php echo $stylePath; ?>";
      $('#check-email').html('<img src="'+style+'img/notok.png">');  
    } 
    else if(validateEmail(email))
    {
      $.ajax({
        url: 'http://clickmobile.com/admin.php/user/checkEmail',
        type:'POST',
        data: 'email='+email,
        asynce :true,
        success: function(result){
            $('#check-email').html(result);   
        }
      })
    }
    else
    {
      var style = "<?php echo $stylePath; ?>";
      $('#check-email').html('<img src="'+style+'img/notok.png">');   
    }    
  })
</script>
</body>
</html>
